<template>
  <div id="app">
    <!--    顶部导航栏-->
      <div class="line"></div>
      <el-menu
        :default-active="activeIndex2"
        class="el-menu-demo"
        mode="horizontal"
        @select="handleSelect"
        background-color="#545c64"
        text-color="#fff"
        active-text-color="#ffd04b">
        <el-col :span="2" ><el-menu-item index="1" @click="jump('http://localhost:8333//swagger-ui.html#/')">关于我们</el-menu-item></el-col>
        <el-col :span="2"><el-menu-item index="1">公告</el-menu-item></el-col>
        <el-col :span="2">
          <el-submenu index="2">
          <template slot="title">任务</template>
          <el-menu-item index="2-1" @click="ToTaskList">任务列表</el-menu-item>
          <el-menu-item index="2-2" @click="ToTaskInProgress">正在执行</el-menu-item>
          <el-menu-item index="2-3" @click="ToMyRelease">我的发布</el-menu-item>
          <el-menu-item index="2-4" @click="ToMyFinishedTask">已完成</el-menu-item>
          <el-menu-item index="2-5" @click="ToAddTask">发布任务</el-menu-item>
        </el-submenu>
        </el-col>
        <el-col :span="6">
          <el-menu-item index="3">
            <el-input placeholder="搜任务" >
              <el-button slot="append" icon="el-icon-search" ></el-button>
            </el-input>
          </el-menu-item></el-col>
        <el-col :span="2">
          <el-menu-item index="4">
            <el-button type="grey" icon="el-icon-message" circle></el-button>
          </el-menu-item>
        </el-col>
        <el-col :span="3" offset="6">
          <el-submenu index="5">
            <template slot="title">个人中心</template>
            <el-menu-item index="5-1" @click="ToInformation">设置信息</el-menu-item>
            <el-menu-item index="5-2" @click="ToHistory">历史评价记录</el-menu-item>
            <el-menu-item index="5-3" @click="ToDebate">申诉</el-menu-item>
            <el-menu-item index="5-4" @click="logout">退出登录</el-menu-item>
          </el-submenu>
        </el-col>
      </el-menu>

    <div class="page">
      <div class="gva-card-box">
        <div class="gva-card gva-top-card">
          <div class="gva-top-card-left">
            <div class="gva-top-card-left-title">早上好，请开始一天的工作吧</div>
            <div class="gva-top-card-left-dot">今日晴，0℃ - 5℃，天气寒冷，注意添加衣物。</div>
            <div class="gva-top-card-left-rows">
              <el-row>
                <el-col :span="8" :xs="24" :sm="8">
                  <div class="flex-center">
                    <i class="el-icon-sort icon" />发布的任务数量 (11)
                  </div>
                </el-col>
                <el-col :span="8" :xs="24" :sm="8">
                  <div class="flex-center">
                    <i class="el-icon-s-custom icon" />接受的任务数量 (21)
                  </div>
                </el-col>
                <el-col :span="8" :xs="24" :sm="8">
                  <div class="flex-center">
                    <i class="el-icon-s-comment icon" />您的好评率 (100%)
                  </div>
                </el-col>
              </el-row>
            </div>
            <div>
              <div class="gva-top-card-left-item">
                后端代码地址：
                <a
                  style="color:#409EFF"
                  target="view_window"
                  href="https://gitee.com/greenwood-drgon/pubinfo"
                >https://gitee.com/greenwood-drgon/pubinfo</a>
              </div>
              <div class="gva-top-card-left-item">
                前端代码地址：
                <a
                  style="color:#409EFF"
                  target="view_window"
                  href="https://gitee.com/richerlv/gwir_vue"
                >https://gitee.com/richerlv/gwir_vue</a>
              </div>
            </div>
          </div>
          <img src="@/assets/dashboard.png" class="gva-top-card-right" alt>

        </div>
      </div>
      <div class="gva-card-box">
        <el-card class="gva-card quick-entrance">
          <template #header>
            <div class="card-header">
              <span>快捷入口</span>
            </div>
          </template>
          <el-row :gutter="20">
            <el-col
              v-for="(card, key) in toolCards"
              :key="key"
              :span="4"
              :xs="8"
              class="quick-entrance-items"
              @click="toTarget(card.name)"
            >
              <div class="quick-entrance-item">
                <div class="quick-entrance-item-icon" :style="{ backgroundColor: card.bg }">
                  <i :class="card.icon" :style="{ color: card.color }" />
                </div>
                <p>{{ card.label }}</p>
              </div>
            </el-col>
          </el-row>
        </el-card>
        <!-- <div class="quick-entrance-title"></div> -->
      </div>
      <div class="gva-card-box">
        <div class="gva-card">
          <div class="card-header">
            <span>数据统计</span>
          </div>
          <div class="echart-box">
            <el-row :gutter="20">
              <el-col :xs="24" :sm="18">
                <echarts-line />
              </el-col>
              <el-col :xs="24" :sm="6">
                <dashboard-table />
              </el-col>
            </el-row>
          </div>
        </div>
      </div>
    </div>
      <router-view></router-view>
    </div>
</template>

<script>
import Vue from 'vue'
import Information from './Information'
import History from './History'
import router from '../../router'
import TaskList from './TaskList'
export default {
  name: 'AppIndex',
  components: {
    Information,
    History,
    TaskList
  },
  data () {
    return {
      activeIndex: '1',
      activeIndex2: '1',
      ifshow: true
      // Tasks: [{data: '', id: 0, publisherName: '', reward: 0, tag_id: '', title: ''}]
    }
  },
  methods: {
    handleSelect (key, keyPath) {
      console.log(key, keyPath)
    },
    ToDebate () {
      router.push(({path: '/Debate'}))
    },
    ToAddTask () {
      router.push(({path: '/AddTask'}))
    },
    ToTaskList () {
      router.push(({path: '/TaskList'}))
    },
    ToMyFinishedTask () {
      router.push(({path: '/MyFinishedTask'}))
    },
    ToInformation () {
      router.push({path: '/Information'})
    },
    ToHistory () {
      router.push({path: '/History'})
    },
    ToTaskInProgress () {
      router.push({path: '/TaskInProgress'})
    },
    ToMyRelease () {
      router.push(({path: '/MyRelease'}))
    },
    jump (e) {
      window.open(e, '_blank')
      // window.location.href = e
    },
    logout () {
      this.$axios.get('/user/logout')
        .then(res => {
          if (res.data.status === 100) { // 100可换\
            console.log(res.data)
            // 删除localStrage
            localStorage.removeItem('token')
            alert(res.data.data)
            router.replace('/login')
          }
        }).catch(err => {
          console.log(err)
          this.$router.replace('/login')
        })
    }
  }
}
var Ctor = Vue.extend()
new Ctor().$mount('#app')
</script>

<style lang="scss" scoped>
@mixin flex-center {
  display: flex;
  align-items: center;
}
.page {
  background: #f0f2f5;
  padding: 0;
  .gva-card-box{
    padding: 12px 16px;
    &+.gva-card-box{
      padding-top: 0px;
    }
  }
  .gva-card {
    box-sizing: border-box;
    background-color: #fff;
    border-radius: 2px;
    height: auto;
    padding: 26px 30px;
    overflow: hidden;
    box-shadow: 0 0 7px 1px rgba(0, 0, 0, 0.03);
  }
  .gva-top-card {
    height: 260px;
    @include flex-center;
    justify-content: space-between;
    color: #777;
    &-left {
      height: 100%;
      display: flex;
      flex-direction: column;
      &-title {
        font-size: 22px;
        color: #343844;
      }
      &-dot {
        font-size: 14px;
        color: #6B7687;
        margin-top: 24px;
      }
      &-rows {
        // margin-top: 15px;
        margin-top: 18px;
        color: #6B7687;
        width: 600px;
        align-items: center;
      }
      &-item{
        +.gva-top-card-left-item{
          margin-top: 24px;
        }
        margin-top: 14px;
      }
    }
    &-right {
      height: 600px;
      width: 600px;
      margin-top: 28px;
    }
  }
  ::v-deep(.el-card__header){
    padding:0;
    border-bottom: none;
  }
  .card-header{
    padding-bottom: 20px;
    border-bottom: 1px solid #e8e8e8;
  }
  .quick-entrance-title {
    height: 30px;
    font-size: 22px;
    color: #333;
    width: 100%;
    border-bottom: 1px solid #eee;
  }
  .quick-entrance-items {
    @include flex-center;
    justify-content: center;
    text-align: center;
    color: #333;
    .quick-entrance-item {
      padding: 16px 28px;
      margin-top: -16px;
      margin-bottom: -16px;
      border-radius: 4px;
      transition: all 0.2s;
      &:hover{
        box-shadow: 0px 0px 7px 0px rgba(217, 217, 217, 0.55);
      }
      cursor: pointer;
      height: auto;
      text-align: center;
      // align-items: center;
      &-icon {
        width: 50px;
        height: 50px !important;
        border-radius: 8px;
        @include flex-center;
        justify-content: center;
        margin: 0 auto;
        i {
          font-size: 24px;
        }
      }
      p {
        margin-top: 10px;
      }
    }
  }
  .echart-box{
    padding: 14px;
  }
}
.icon {
  font-size: 20px;
  color: rgb(85, 160, 248);
  width: 30px;
  height: 30px;
  margin-right: 10px;
  @include flex-center;
}
.flex-center {
  @include flex-center;
}

//小屏幕不显示右侧，将登陆框居中
@media (max-width: 750px) {
  .gva-card {
    padding: 20px 10px !important;
    .gva-top-card {
      height: auto;
      &-left {
        &-title {
          font-size: 20px !important;
        }
        &-rows {
          margin-top: 15px;
          align-items: center;
        }
      }
      &-right {
        display: none;
      }
    }
    .gva-middle-card {
      &-item {
        line-height: 20px;
      }
    }
    .icon {
      font-size: 18px;
    }
  }
}
</style>
